package testingtesting.android.project;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.os.Bundle;
import android.os.Handler;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.Gallery;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class testing extends Activity
{
	RelativeLayout mRelativeLayout;
	LinearLayout mButtonLinks;
	LinearLayout mButtonRechts;
	Context context;
	DrawView mDrawView;
	Paint paint;
	Path path;
	Thread infinitLoop = new Thread();
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        
        mDrawView = new DrawView(this);
        mRelativeLayout = new RelativeLayout(this);
        mButtonLinks = new LinearLayout(this);
        mButtonRechts = new LinearLayout(this);
        
        ImageView buttonLinks = new ImageView(this);
        buttonLinks.setImageResource(R.drawable.linksbutton);
        buttonLinks.setClickable(true);
        mButtonLinks.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        mButtonLinks.setGravity(Gravity.LEFT | Gravity.BOTTOM);
        mButtonLinks.setOrientation(0);
        mButtonLinks.addView(buttonLinks);
        
        ImageView buttonRechts = new ImageView(this);
        buttonRechts.setImageResource(R.drawable.rechtsbutton);
        buttonRechts.setClickable(true);
        mButtonRechts.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        mButtonRechts.setGravity(Gravity.RIGHT | Gravity.BOTTOM);
        mButtonRechts.setOrientation(0);        
        mButtonRechts.addView(buttonRechts);
        
		buttonLinks.setOnClickListener(mButtonLinksListener);
		buttonRechts.setOnLongClickListener(mButtonRechtsListener);
        
        mRelativeLayout.setBackgroundColor(Color.WHITE);
        mRelativeLayout.addView(mButtonRechts);
        mRelativeLayout.addView(mButtonLinks);
        mRelativeLayout.addView(mDrawView);
    }

    private OnClickListener mButtonLinksListener = new OnClickListener() 
    {
        public void onClick(View mButtonLinks) 
        {
        	mRelativeLayout.setBackgroundColor(Color.YELLOW);
        }
    };
    
    private OnLongClickListener mButtonRechtsListener = new OnLongClickListener() 
    {
        public boolean onLongClick(View mButtonRechts) 
        {
        	mRelativeLayout.setBackgroundColor(Color.RED);
			return false;
        }
    };

    protected void onStart()
    {
    	super.onStart();
    }
    
    protected void onRestart()
    {
    	super.onRestart();
    }

    protected void onResume()
    {
    	super.onResume();
    	Thread mainLoop = new Thread() 
    	{
    		public void run()
    		{
    			try 
    			{
    				while (true)
    				{
    					sleep(10);
    					mDrawView.updatePath();
    					mDrawView.postInvalidate();
    				}
				} 
    			catch (InterruptedException e) 
    			{
					e.printStackTrace();
				}
    		}
    	};  
    	mainLoop.start();	
        setContentView(mRelativeLayout);
    }

    protected void onPause()
    {
    	super.onPause();
    }

    protected void onStop()
    {
    	super.onStop();
    }

    protected void onDestroy()
    {
    	super.onDestroy();
    }
}

